package com.hospital.insurancedip.async;

import com.alibaba.fastjson.JSON;
import com.hospital.insurancedip.module.controller.vo.AddSendTask;
import com.hospital.insurancedip.module.service.AllPaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @author lvyao
 * @description 加入任务方法类
 * @date 2022/6/1
 */
@Service
@Slf4j
public class AddTaskFunc {
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private AllPaymentService allPaymentService;
    @Async
    public String addTask(AddSendTask params) {
        String localString = "";
        try {
            String hisRefundUrl = allPaymentService.getHisAddTak();
            ResponseEntity<String> response = restTemplate.postForEntity(hisRefundUrl, params, String.class);
            localString = response.getBody().toString();
        } catch (Exception e) {
            log.error(e.toString() + "====================加入时间轮任务失败入参：" + JSON.toJSONString(params));
            localString = e.toString();
        }
        return localString;
    }
}
